﻿using System.Reflection;

namespace NMA.Application
{
    using NMA.Domain.Model.Service.Application;
    using NMA.Domain.Model.Repository;
    using NMA.Infrastructure.EventAggregator;
    using NMA.Infrastructure.NHibernate.Service.Event;
    using NMA.Infrastructure.Logging;
    using NMA.Infrastructure.NHibernate.Container;
    using NMA.Infrastructure.Security;    

    public class UserFacade : IUserFacade
    {
        #region variables       
        
        private readonly IConsumer<AuditEvent> _auditHandler = null;
        private readonly IAuditFactory _auditFactory = null;
        private readonly ICryptography _cryptography = null;
        private static readonly ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        #endregion

        #region ctors        

        public UserFacade() : this(IoC.GetInstance<IUserRepository>(),
                                   IoC.GetInstance<IConsumer<AuditEvent>>(),
                                   IoC.GetInstance<IAuditFactory>(),
                                   IoC.GetInstance<ICryptography>())
        {
            UserName = "";
        }

        public UserFacade(IUserRepository userRepository, 
                          IConsumer<AuditEvent> auditHandler, 
                          IAuditFactory auditFactory,
                          ICryptography cryptography)
        {
            UserRepository = userRepository;
            _auditHandler = auditHandler;
            _auditFactory = auditFactory;
            _cryptography = cryptography;
        }

        #endregion

        #region implement functions

        public IUserRepository UserRepository { get; private set; }

        public string UserName { get; set; }

        public bool ValidateUser(string userName, string password)
        {
            return true;
        }

        #endregion
    }
}